//
//  FMDBManager.m

//
//  Created by qianfeng on 15/9/2.
//  Copyright (c) 2015年 qianfeng. All rights reserved.
//

#import "FMDBManager.h"

@implementation FMDBManager
+(instancetype)shareInstance
{
    static FMDBManager*manager=nil;
    @synchronized(self)
    {
        if (manager==nil) {
            manager=[[FMDBManager alloc]init];
        }
        return  manager;
    }

}
-(instancetype)init
{
    self=[super init];
    if (self) {
        NSString*filePath=[NSHomeDirectory() stringByAppendingString:@"/Documents/Products.db"];
        NSLog(@"filePath==%@",filePath);
        self.dataBase=[FMDatabase databaseWithPath:filePath];
        if (![self.dataBase open]) {
            NSLog(@"数据库打开失败");
        }
        if (![self.dataBase executeUpdate:@"create table if not exists Products(id integer primary key autoincrement,iconPath text,price text,discount text,num integer )"])
        {
            NSLog(@"创建失败");
        }
  
        if (![self.dataBase executeUpdate:@"create table if not exists Cloth(id integer primary key autoincrement,iconPath text,title text,catid text)"])
        {
            NSLog(@"创建失败1");
        }
        
        if (![self.dataBase executeUpdate:@"create table if not exists Detail(id integer primary key autoincrement,iconPath text,price text,catid text)"])
        {
            NSLog(@"创建失败2");
        }
    
    }
    return self;
}




@end
